package com.lex.newbasketball.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lex.newbasketball.R;
import com.lex.newbasketball.entity.WonderEntity;
import com.lex.newbasketball.fragment.ShowTimeFragment;

import java.util.List;
import java.util.Map;

public class WonderAdapter extends BaseAdapter{
    private Context context;
    private List<WonderEntity>wonderEntityList;

    public WonderAdapter(Context context, List<WonderEntity> wonderEntityList){
        this.context = context;
        this.wonderEntityList = wonderEntityList;
    }

    @Override
    public int getCount() {
        return wonderEntityList.size();
    }

    @Override
    public Object getItem(int i) {
        return wonderEntityList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    public class ViewHolder{
        private ImageView head, picture;
        private TextView name, address, time, type, feel;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup parent) {
        WonderEntity wonderEntity = wonderEntityList.get(i);
        ViewHolder viewHolder = null;
        if (viewHolder == null){
            convertView = convertView.inflate(context, R.layout.item_show_time_list_item, null);
            viewHolder = new ViewHolder();
            viewHolder.head = (ImageView) convertView.findViewById(R.id.today_star_head);
            viewHolder.picture = (ImageView) convertView.findViewById(R.id.today_star_picture);
            viewHolder.name = (TextView) convertView.findViewById(R.id.today_star_name);
            viewHolder.address = (TextView) convertView.findViewById(R.id.today_star_address);
            viewHolder.time = (TextView) convertView.findViewById(R.id.today_star_time);
            viewHolder.type = (TextView) convertView.findViewById(R.id.today_star_phone_type);
            viewHolder.feel = (TextView) convertView.findViewById(R.id.today_star_feel);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.head.setImageResource(wonderEntity.getHead());
        viewHolder.picture.setImageResource(wonderEntity.getPicture());
        viewHolder.name.setText(wonderEntity.getName());
        viewHolder.address.setText(wonderEntity.getAddress());
        viewHolder.time.setText(wonderEntity.getTime());
        viewHolder.type.setText(wonderEntity.getType());
        viewHolder.feel.setText(wonderEntity.getFeel());
        return convertView;
    }
}
